﻿@model IEnumerable<GheSofa.Models.SanPham>

@{
    ViewBag.Title = "Kết quả tìm kiếm";
}
<div class="covercenter">
    @{Html.RenderAction("khungtimkiem", "sanpham");}

    <div class="columncenter">
        <div class="header-center">KẾT QUẢ TÌM KIẾM</div>

        @if (Model.Count() < 1)
        {
            <div style="width: 580px">
                <div class="noidunggiua" style="padding: 10px;">
                    <div class="noidungphu">@Html.Raw(ViewBag.KhongTimThay) "@Html.Raw(ViewBag.Chuoi)"</div>
                </div>
            </div>
        }
        else
        {
            <div style="width: 580px">
                @foreach (var item in Model)
                {
                    int _gia = (int)item.Gia;
                    string gia = _gia.ToString("c");
                    gia = gia.Substring(1, gia.LastIndexOf(".") - 1);
                    <div class="sanpham">
                        <a title="Chi tiết" href="/sanpham/chitietsanpham?masp=@Html.DisplayFor(modelItem => item.MaSP).ToString().Trim()">
                            <div>
                                <img src="@Url.Content("~/" + @Html.DisplayFor(modelItem => item.Hinh))"/></div>
                        </a>
                        <div class="tensanpham" style="color: Black">
                            <table align="center">
                                <tr height="40px" valign="middle">
                                    <td><b>@Html.DisplayFor(modelItem => item.TenSP)</b></td>
                                </tr>
                            </table>
                        </div>
                        <div style="color: #FF0000"><b>Giá: @gia VNĐ</b></div>
                        <table>
                            <tr>
                                <td align="right" style="width: 100px; padding-left: 7px; padding-right: 5px">
                                    <div class="muahang">
                                        @{
                                            if (item.SoLuong > 0)
                                            { <a title="Thêm sản phẩm vào giỏ hàng" href="/Cart/giohangthem?masp=@Html.DisplayFor(x => item.MaSP)"><b>Mua hàng</b></a>}
                                            else
                                            { <b title="Hết hàng">Hết hàng</b>}
                                        }
                                    </div>
                                </td>
                                <td align="left" style="width: 60px; padding-left: 5px; padding-right: 10px">
                                    <div class="chitiet">
                                        <a href="/sanpham/chitietsanpham?masp=@Html.DisplayFor(modelItem => item.MaSP).ToString().Trim()">Chi tiết</a>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                }

            </div>
            <div class="clear"></div>      }
    </div>
    <div style="width: 580px; text-align: center; margin: 5px 5px 7px 5px">
        @{Html.RenderAction("PageIndex", "paging", new { currentpage = "sanpham/timkiem?chuoitk=" + @ViewBag.maloai, totalpages = ViewBag.TotalPages });}
    </div>
</div>
